import 'package:flutter/material.dart';

class SplashPage extends StatefulWidget {
  SplashPage({Key key}) : super(key: key);

  @override
  _SplashPageState createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  bool isStartHomePage = false;
  void initState(){
    super.initState();
    countDown();
  }
  void _goToHomePage(){
    if(!isStartHomePage){
      Navigator.of(context).pushNamedAndRemoveUntil('/',(route) => route == null);//销毁页面
      isStartHomePage=true;
    }
  }
  void countDown(){
    var duration = Duration(seconds: 3);
    new Future.delayed(duration,_goToHomePage);
  }
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: _goToHomePage,//设置页面点击事件
      child: Image.asset("images/splash_imag.jpg",fit: BoxFit.cover,),
    );
  }
}